﻿using System.IO;
using System.Threading;
using System.Threading.Tasks;

namespace FileStorage.Provider
{
    public interface IStorageProvider
    {
        /// <summary>
        /// 保存文件
        /// </summary>
        /// <param name="input"></param>
        /// <param name="metadata"></param>
        /// <param name="cancellation"></param>
        /// <returns>文件访问地址URI</returns>
        ValueTask<string> SaveAsync(Stream input, FileMetadata metadata, CancellationToken cancellation);

        /// <summary>
        /// 获取文件元数据
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="cancellation"></param>
        /// <returns></returns>
        ValueTask<FileMetadata> GetMetadata(string uri, CancellationToken cancellation);

        /// <summary>
        /// 获取文件读取流
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="cancellation"></param>
        /// <returns></returns>
        ValueTask<Stream> OpenReadAsync(string uri, CancellationToken cancellation);

        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="cancellation"></param>
        /// <returns></returns>
        ValueTask DeleteAsync(string uri, CancellationToken cancellation);
    }
}
